package com.ybl.store.common.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.ybl.store.backend.dto.UserInfoDTO;

/**
 * 用户上下文
 */
public final class UserContext {

    private static final ThreadLocal<UserInfoDTO> USER_INFO_THREAD_LOCAL = new TransmittableThreadLocal<>();

    public static void set(UserInfoDTO user) {
        USER_INFO_THREAD_LOCAL.set(user);
    }

    public static UserInfoDTO get() {
        return USER_INFO_THREAD_LOCAL.get();
    }

    public static void remove() {
        USER_INFO_THREAD_LOCAL.remove();
    }
}
